/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.epam.expertsys.web;

import com.epam.expertsys.blogic.Request;
import com.epam.expertsys.dbconn.RequestDAOH2;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Admin
 */
public class TableRequestsServlet extends AbstractServletCommand {

    @Override
    public void process(HttpServletRequest req, HttpServletResponse resp)
            throws SQLException, ServletException, IOException {

        ServletContext servCont = this.getServletContext();
        String login = (String) req.getSession().getAttribute("login");
        RequestDAOH2 reqDAO = (RequestDAOH2) servCont.getAttribute("requestDAO");

        List<Request> requests = reqDAO.getRequestsByLogin(login);

        req.setAttribute("requestList", requests);

        RequestDispatcher reqDisp = req.getRequestDispatcher("/auth/reqtable.jsp");
        reqDisp.forward(req, resp);
    }
}
